import tty from 'node:tty'
import util from 'node:util'
import querystring from 'node:querystring'
import qs from 'qs'


export function mixin<T extends object, U extends object>(
  dest:T, src:U, redefine:boolean=true) {
  Object.getOwnPropertyNames(src).forEach(name=>{
    if (!redefine && Object.prototype.hasOwnProperty.call(dest, name)) {
      return
    }

    const descriptor = Object.getOwnPropertyDescriptor(src, name)!

    Object.defineProperty(dest, name, descriptor)
  })

  return dest
}

export function defineGetter(target:object, name:string, getter:()=>any) {
  Object.defineProperty(target, name, {
    enumerable: true,
    configurable: true,
    get: getter
  })
} 

export function sendFile() {}

export function stringify() {}

export function debug() {
  if(typeof process === 'undefined') {

  } else {

  }
}

export function parseExtendedQueryString(str:string) {
  return qs.parse(str, {
    allowPrototypes: true
  })
}

export function isAbsolute(path:string) {}

export function flatten<T extends ArrayLike<any>>(arr:T) {
  for(let i = 0; i < arr.length; i++) {
    const value = arr[i]

    if(Array.isArray(value)) {

    } else {
      
    }

  }
}